package actions.loadpages;

import java.sql.SQLException;
import java.util.Map;

import javax.jdo.annotations.Persistent;

import com.google.appengine.api.datastore.Blob;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import dominio.Producto;


public class loadModProducto extends ActionSupport{

	private static final long serialVersionUID = 1L;
	private Long id;
	
	private String name;
	
	private String descripcion;

	private double precio;

	private int stock;

	private Blob fileBlob;

	private Long id_propietario;

	private Map<String, Object> session;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescripcion() {
		return descripcion;
	}

	public void setDescripcion(String descripcion) {
		this.descripcion = descripcion;
	}

	public double getPrecio() {
		return precio;
	}

	public void setPrecio(double precio) {
		this.precio = precio;
	}

	public int getStock() {
		return stock;
	}

	public void setStock(int stock) {
		this.stock = stock;
	}

	public Blob getFileBlob() {
		return fileBlob;
	}

	public void setFileBlob(Blob fileBlob) {
		this.fileBlob = fileBlob;
	}

	public Long getId_propietario() {
		return id_propietario;
	}

	public void setId_propietario(Long id_propietario) {
		this.id_propietario = id_propietario;
	}

	public String execute(){
		

		session = ActionContext.getContext().getSession();
		if (session.get("usu")!=null){
			Producto prod = Producto.read(id, false);
			id=prod.getId();
			name=prod.getName();
			descripcion=prod.getDescripcion();
			precio=prod.getPrecio();
			stock=prod.getStock();
			fileBlob=prod.getFileBlob();
			id_propietario=prod.getId_propietario();
			return SUCCESS;
			
		}
		else{
			return ERROR;
		}
		
	}

	public Map getSession() {
		return session;
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

}